package Group9.TodoManager.View;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * This class is for showing a dialog for About feature of the application
 * @author volkan cambazoglu
 * @author Rupesh
 */
public class AboutView extends JPanel {
    
    private JDialog jDialog;
    
    /**
     * Default Constructor. creates an instance of the about view
     * Initializes the components
     */
    public AboutView() {
        this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
        GridBagConstraints c = new GridBagConstraints();
        JPanel titlepanel = new JPanel(new GridBagLayout());
        JLabel title = new JLabel("<html><u>Course: User Interface Programming" +
        						  " I</u></html>", JLabel.CENTER);        
        c.gridx = 0;
        c.gridy = 0;
        titlepanel.add(title,c);
        c.gridx = 0;
        c.gridy = 1;
        titlepanel.add(new JLabel("<html><u>Group Members</u></html>"),c);

        add(titlepanel);
        
        JPanel pa = new JPanel(new GridBagLayout());        
        c.gridy=2;
        pa.add(new JLabel("Rupesh Acharya"),c);       
        c.gridy=3;
        pa.add(new JLabel("Pankaj Kulkarni"),c);        
        c.gridy=4;
        pa.add(new JLabel("Sandra Nystrom"),c);        
        c.gridy=5;
        pa.add(new JLabel("Volkan Cambazoglu"),c);        
        
        add(pa);        

        JButton okbutton = new JButton("Ok");
        okbutton.setAlignmentX(CENTER_ALIGNMENT);
        add(okbutton);

        okbutton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                jDialog.setVisible(false);
            }
        });       

        setSize(350,150);
    }

    /**
     * Setter method of the parent window
     * @param jDial parent window
     */
    public void setParentWindow(JDialog jDial){
        jDialog = jDial;
        jDial.setTitle("About");
    }
}
